class_name WeaponC_FollowTarget
extends WeaponC

var is_control_by_mouse:bool:
	get:
		if not weapon or not weapon.owner_entity:
			return false
		var entity_controller_c:BaseComponent = weapon.owner_entity.get_component_by_name("ControllerComponent")
		if not entity_controller_c:
			return false
		return entity_controller_c is ManualControllerComponent

func init_component(weapon:Weapon):
	super.init_component(weapon)
func get_target_point():
	if is_control_by_mouse:
		return get_global_mouse_position()
	elif true:
		# TODO 返回AI所选目标的位置
		return null
	else:
		return null
func follow():
	var target = get_target_point()
	if not target:
		return
	weapon.look_at(target)
func toggle_follow(val:bool):
	enable = val
func equip():
	super.equip()
	pass
func unequip():
	super.unequip()
func discard():
	super.discard()

func _init() -> void:
	weapon_component_name = "WeaponC_FollowTarget"
func _process(delta: float) -> void:
	if not weapon or not weapon.enable or not enable or not inited:
		return
	follow()
